<?php
namespace app\admin\logic;
use app\common\model\Config;
use app\common\logic\BaseLogic;

use think\Db;
Class ConfingsLogin extends BaseLogic
{
    public function listing($page_size = 10)
    {
        $where = [];
        //$r = Config::where($where)->paginate($page_size)->toArray();
        $r = Db::table('config')->paginate($page_size)->toArray();
        return $r;
    }


    public function create($data)
    {
        $data['create_time'] = time();
        $data['update_time'] = time();
        unset($data['file']);
        Db::table('config')->insert($data);
        return true;
    }

    public function update($data, $methods = 'post')
    {
        if ($methods === 'get') {
            $r = Db::table('config')->where(['id'=>$data])->find();
        } else {
             //var_dump($data);die;
            $r = Db::table('config')->where(['id'=>$data['id']])->update($data);
        }
        return $r;
    }

    public function delete($ids)
    {
        $str = trim($ids,',');
        $_arr = explode(',',$str);
        $where[] = ['id','in',$_arr];
        $r = Db::table('config')->where($where)->delete();
        return $r;
    }
}
